Apple, the Apple logo, and Macintosh are registered trademarks of Apple Computer, Inc.
Mac and OpenDoc are trademarks of Apple Computer, Inc.
Introduction
The OpenDoc Dispatcher can be extended by developers, to handle additional event types, perhaps associated with some exotic input device like a glove. The same mechanism can also be used to “patch” the dispatcher. See Patching OpenDoc.
Note: Most developers should not need to extend or patch the dispatcher. Please think very carefully before doing so.
ODDispatcher maintains a dictionary of dispatch modules, with the event type as the key. When ODDispatcher::Dispatch() is called, the dispatcher looks up a dispatch module for the supplied event type, and calls its Dispatch() method.
To extend the dispatcher, a developer must implement a subclass of ODDispatchModule, and install it in the dispatcher.
Defining a Dispatch Module
ODDispatchModule is a System Object Model™ (SOM) class, just like ODPart, and must be subclassed (in IDL). The subclass should have an Init<ClassName> method, and should override the Dispatch() method:
The Init<ClassName> method should call InitDispatchModule, and the Dispatch() method will presumably locate a part to handle the event, and call its HandleEvent() method.
New in DR3: There is a new method Redispatch() defined in ODDispatcher. When the standard OpenDoc dispatch module transforms an event (eg. mouse down into menu event), it redispatches. This means that dispatch module patches can intercept the transformed event. As a result, the Dispatch() method of ODDispatchModule now has an eventInfo parameter containing the addition information associated with some of the transformed events (eg. embedded frame).
Installing a Dispatch Module
A dispatch module should be installed by calling ODDispatcher::AddDispatchModule:
void AddDispatchModule(in ODEventType eventType, in ODDispatchModule dispatchModule);
The installation could take place in a part's initialization method, or in a Shell Plug-In.
Monitors
A dispatch module can also be installed as a monitor, by calling ODDispatcher::AddMonitor() instead:
void AddMonitor(in ODEventType eventType, in ODDispatchModule dispatchModule);
Unlike regular dispatch modules, multiple monitors can be installed for a single event type. The dispatcher calls the Dispatch() method of all monitors for an event before calling the Dispatch() method of the single regular dispatch module for that event type. The Boolean result returned by the monitors' implementation of Dispatch() is ignored. In other words, a monitor can't interfere with the regular dispatching of the event, unless it actually changes the event type on the fly [Shudder].